package com.btb.adapter.schedule;

import java.math.BigInteger;
import java.util.Objects;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import com.btb.adapter.constant.Constants;
import com.btb.adapter.constant.EventType;
import com.btb.adapter.constant.QueryType;
import com.btb.adapter.model.TaskConfig;
import com.btb.adapter.service.CallBackService;
import com.btb.adapter.service.TaskConfigService;
import com.btb.adapter.service.UpChainBlockService;
import com.btb.adapter.service.UpChainEvent;
import com.btb.adapter.service.UpChainEventService;
import com.btb.adapter.service.WatchTransferService;

import lombok.extern.slf4j.Slf4j;

/**
 * @author hqbzl 英雄和鱼上链任务
 */
@Slf4j
//@Component
@EnableScheduling
public class UpChainSchedule {

	@Autowired
	private UpChainBlockService upChainHeroService;
	@Autowired
	private TaskConfigService taskConfigService;
	@Autowired
	private WatchTransferService watchTransferService;
	@Autowired
	private UpChainEventService upChainEventService;
	@Autowired
	private UpChainEvent upChainEvent;
	@Autowired
	private CallBackService callBackService;
	/**
	 * 英雄上链任务
	 */
	@Scheduled(initialDelay = 100, fixedDelay = 1000 * 1)
	public void upChainFishSchedule() {
		log.error("upChainFishSchedule is start");
		upChainHeroService.upChainHero();
		log.error("upChainFishSchedule is end");
	}

	/**
	 * 鱼上链任务
	 */
	@Scheduled(initialDelay = 100, fixedDelay = 1000 * 1)
	public void upChainHeroSchedule() {
		log.error("upChainHeroSchedule is start");
		upChainHeroService.upChainFish();
		log.error("upChainHeroSchedule is end");
	}

	/**
	 * 英雄远程http通知任务任务
	 */
	@Scheduled(initialDelay = 100, fixedDelay = 1000 * 1)
	public void callBackHeroSchedule() {
		log.error("callBackHeroSchedule is start");
		callBackService.upHero();
		log.error("callBackHeroSchedule is end");
	}

	/**
	 * 鱼远程http通知任务任务
	 */
	@Scheduled(initialDelay = 100, fixedDelay = 1000 * 1)
	public void callBackFishSchedule() {
		log.error("callBackFishSchedule is start");
		callBackService.upFish();
		log.error("callBackFishSchedule is end");
	}

	/**
	 * 英雄上链event事件处理任务
	 */
	@Scheduled(initialDelay = 100, fixedDelay = 1000 * 1)
	public void upChainHeroEventSchedule() {
		log.error("upChainHeroEventSchedule is start");
		upChainEvent.start(EventType.HERO_CHAIN_UP, Constants.UP_CHAIN_HERO_EVENT);
		log.error("upChainHeroEventSchedule is end");
	}

	/**
	 * 鱼上链event事件处理任务
	 */
	@Scheduled(initialDelay = 100, fixedDelay = 1000 * 1)
	public void upChainFishEventSchedule() {
		log.error("upChainFishEventSchedule is start");
		upChainEvent.start(EventType.FISH_CHAIN_UP, Constants.UP_CHAIN_FISH_EVENT);
		log.error("upChainFishEventSchedule is end");
	}

}
